package safari.model.free;

import java.sql.SQLException;
import java.util.List;

import safari.model.common.ListVO;
import safari.model.common.PagingBean;

public class FreeBoardServiceImpl implements FreeBoardService {
	private FreeBoardDao fd;
	public FreeBoardServiceImpl(FreeBoardDao fd){
		this.fd = fd;
	}
	@Override
	public void freeBoardRegister(FreeBoardVO fvo) throws SQLException {
		fd.freeBoardRegister(fvo);
	}

	@Override
	public void freeBoardUpdate(FreeBoardVO fbvo) throws SQLException {
		fd.freeBoardUpdate(fbvo);
		
	}
	@Override
	public FreeBoardVO freeBoardUpdateView(int no) throws SQLException {
		return fd.freeBoardUpdateView(no);
	}

	@Override
	public void freeBoardDelete(int no) throws SQLException {
		fd.freeBoardDelete(no);
		
	}

	@Override
	public FreeBoardVO freeBoardShowContent(String paramNo) throws SQLException {
		int no = Integer.parseInt(paramNo);
		return fd.freeBoardShowContent(no);
	}

	@Override
	public void freeBoardUpdateHits(int no) throws SQLException {
		
	}

	@Override
	public ListVO freeBoardGetAllList(String page) throws SQLException {
		int pn=1;
		if(page != null){
			pn = Integer.parseInt(page);
		}
		List<FreeBoardVO> list = fd.freeBoardGetAllList(pn);
		int totalContents = fd.freeBoardGetTotalContentCount();
		System.out.println(totalContents);
		PagingBean pb = new PagingBean(totalContents, pn);
		
		return new ListVO(list, pb);
	}
	
	@Override
	public void freeBoardReplyRegister(FreeBoardVO fbvo) throws SQLException {
		fd.freeBoardReplyRegister(fbvo);
		fbvo = fd.freeBoardShowContent(fbvo.getNo());
		fd.freeBoardReplyUpdate(fbvo);
		
	}
	@Override
	public FreeBoardVO freeBoardReplyView(String paramNo) throws SQLException {
		int no = Integer.parseInt(paramNo);
		return fd.freeBoardReplyView(no);
	}

	@Override
	public void freeBoardReplyUpdate(FreeBoardVO fvo) throws SQLException {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void freeBoardReplyDelete(int no) throws SQLException {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void freeBoardCommentRegister(FreeBoardCommentVO fbcVO)
			throws SQLException {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void freeBoardCommentUpdate(FreeBoardCommentVO fbcVO)
			throws SQLException {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void freeBoardCommentDelete(int no) throws SQLException {
		// TODO Auto-generated method stub
		
	}

	@Override
	public List<FreeBoardVO> freeBoardSearchByTitleOrContent(String word)
			throws SQLException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<FreeBoardVO> freeBoardSearchByTitle(String word)
			throws SQLException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<FreeBoardVO> freeBoardSearchById(String word)
			throws SQLException {
		// TODO Auto-generated method stub
		return null;
	}



}
